import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Scanner;

//二、4、
public class _2_4 {
    private static String driver="com.mysql.jdbc.Driver";
    private static String url="jdbc:mysql://127.0.0.1:3306/mydb";
    public static void main(String[] args) throws  Exception {
        Class.forName(driver);
        String user;
        String password;
        Scanner in=new Scanner(System.in);
        user=in.next();
        password=in.next();
        in.close();
        Connection conn= DriverManager.getConnection(url,user,password);
        Statement sm=conn.createStatement();
        String sql ="select * from student";
        ResultSet resultSet=sm.executeQuery(sql);
        while (resultSet.next()){
            System.out.println("sno="+resultSet.getInt(1)+",sname="+resultSet.getString(2)
            +",sbirth="+resultSet.getDate(3)+",sdept="+resultSet.getString(4));
        }
    }

    @Test
    public void test(){
        int i=40;
        boolean f = false;
        if((i++==40)&&(f=true)){
            i++;
        }
    }
}
